/*主页无缝滚动*/

window.onload=function(){
    var oBtnLeft = document.getElementById("mscroll-ctrl-prev");
    var oBtnRight = document.getElementById("mscroll-ctrl-next");
    var oList = document.getElementById("autoPlay");
    var oListLi = oList.getElementsByTagName("li");
    var speed = -5;
    var timer = null;
    oList.innerHTML += oList.innerHTML;
    oList.style.width = (oListLi[0].offsetWidth+20) * oListLi.length + "px";
    function autoScroll() {
        oList.style.left = oList.offsetLeft + speed + "px";
        if (oList.offsetLeft < -oList.offsetWidth / 2) {
            oList.style.left = "0px";
        } else if (oList.offsetLeft > 0) {
            oList.style.left = -oList.offsetWidth / 2 + "px";
        }
    }
    function autoPlay(){
        window.clearInterval(timer)
        timer = setInterval(autoScroll, 100);
    }
    oList.onmouseover = function() {
        clearInterval(timer);
    }

    oBtnLeft.onmouseover = function() {
        speed = -5;
        autoPlay();
    }
    
    oBtnRight.onmouseover = function() {
        speed = +5;
        autoPlay();
    }
    
    oBtnLeft.onmouseout = function() {
         window.clearInterval(timer)
    }
    oBtnRight.onmouseout = function() {
         window.clearInterval(timer)
    }
}    



/*大图片幻灯片*/
$(function(){
    var img = $("#imges");
    var ali = $("#imges li");
    var time = null;
    var inow = 0;
    img.width(ali.length*959);
    function tab() {
        img.animate({left:-inow * 959},400)
        $('.bigImageTips li').hide();
        $('.bigImageTips li').eq(inow).show();
    }
    function autoPlay() {
        inow++;
        if (inow >= ali.length) {
            inow = 0
        }
        tab();
    };
    $("#bannerBox .slideLeft").click(function(){
        inow++;
        if(inow>ali.length-1){
            inow=0;
        };
        tab();
    });
    $("#bannerBox .images").mouseover(function(){
        window.clearInterval(time)
    })
    $("#bannerBox .images").mouseout(function(){
       time = window.setInterval(autoPlay, 2000);   
    });
    $("#bannerBox .slideRight").click(function(){
        window.clearInterval(time);
        inow--;
        if(inow<0){
            inow=ali.length-1;
        };
        tab();
        
    })
    time = window.setInterval(autoPlay, 2000);  
})

/*搜索文本框显示*/
$(function(){
    $('#searchBtn').on('click',function(){
        //$('#searchContent').css('visibility','visible');
    });
})

/*新媒体入口*/
$(function(){
    $('#weiboImages').on('mouseover',function(){
        $('#weiboImages img').attr('src','images/weibohover_01.png');
        $('#weiboImages').siblings('p').addClass('promptHover');
    });
    $('#weiboImages').on('mouseout',function(){
        $('#weiboImages img').attr('src','images/weibo_01.png');
        $('#weiboImages').siblings('p').removeClass('promptHover');
    });
})


/*幻灯片*/
$(function(){
    var img = $("#imgess");
    var ali = $("#imgess li");
    var time = null;
    var inow = 0;
    img.width(ali.length*540);
    function tab() {
        img.animate({left:-inow * 540},400);
        $('.tips li').hide();
        $('.tips li').eq(inow).show();;
    }
    function autoPlay() {
        inow++;
        if (inow >= ali.length) {
            inow = 0
        }
        tab();
    };
    $("#contentImage .slideLeft").click(function(){
        inow++;
        if(inow>ali.length-1){
            inow=0;
        };
        tab();
    });
    $("#contentImage .images").mouseover(function(){
        window.clearInterval(time)
    })
    $("#contentImage .images").mouseout(function(){
       time = window.setInterval(autoPlay, 2000);   
    });
    $("#contentImage .slideRight").click(function(){
        window.clearInterval(time);
        inow--;
        if(inow<0){
            inow=ali.length-1;
        };
        tab();
        
    })
    time = window.setInterval(autoPlay, 2000);  
})

/*下拉菜单*/
$(function(){
  $('.header_content .nav .itemsCount').hover(
    function(){
        $(this).children('a').addClass('active');
        $(this).find('.items').show();
    },function(){
        $(this).children('a').removeClass('active');
        $(this).find('.items').hide();  
    }
  )  
})
;
